﻿using FluentNHibernate.Cfg;
using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PAP.Infrastructure.DataAccess.NH
{
    public static class SessionFactory
    {
        #region "Methods"
        public static ISessionFactory CreateMSSQL2008SessionFactory(string connectionString, Action<MappingConfiguration> mappings)
        {
            var sessionFactory = Fluently.Configure()
                .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
                    .Driver(typeof(NHibernate.Driver.Sql2008ClientDriver).AssemblyQualifiedName)
                    .Dialect(typeof(NHibernate.Dialect.MsSql2008Dialect).AssemblyQualifiedName)
                    .ConnectionString(connectionString)
                )
                .Mappings(mappings)
                .BuildSessionFactory();
            return sessionFactory;
        }
        #endregion
    }
}
